/*
 * Comparator.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef COMPARATOR_H_
#define COMPARATOR_H_

#include "SubstrateModel.h"

using namespace std;

/*!
 * \brief Abstract class from which Comparators can be derived. They define the measure of deviation between two displacement fields. Comparators can also implement regularization techniques.
 */

class Comparator {
protected:
	double reg_param;
public:
	/*!
	 * Class Deconstructor
	 */
	virtual ~Comparator() {};
	/*!
	 * Standard constructor without regularization.
	 */
	Comparator(){ reg_param = 0; }
	/*!
	 * Used to build identical Comparator objects. Clones should not use the same memory resources as the template.
	 */
	virtual Comparator * clone() const = 0;
	/*!
	 * This function calls the getComparisonValue function and adds an optional regularization term.
	 */
	virtual double compare_with(SubstrateModel * substrate_model) {return getComparisonValue(substrate_model) + reg_param * getRegularizationValue(substrate_model);};
	/*!
	 * This function defines the key logic of the comparator. The return value must be larger iff the deviations between the displacement field included in the comparator and the one received from the substrate model are larger.
	 */
	virtual double getComparisonValue(SubstrateModel * substrate_model) = 0;
	/*!
	 * Needs to be overwritten if a regularization scheme is to be applied.
	 */
	virtual double getRegularizationValue(SubstrateModel * substrate_model) {return 0;};
	/*!
	 * Returns the current regularization parameter value.
	 */
	virtual double getRegularizationParameter() { return reg_param; };

};


#endif /* COMPARATOR_H_ */
